<?php
class Administrator_Form_News_Catalogue extends Administrator_Model_News_View{
	var $id;
	public function __construct($id){
		$this->id = $id;
		$this->lang = new Nguyen_language_system();
		$this->db = Zend_Registry::get('vicdbsystem');
	}
	public function render(){
		$siteinfo = $this->GetSiteInfo();
		$namevi = '';
		$nameen = '';
		$keyword = '';
		$descript = '';
		$introvi = '';
		$introen = '';
		$section = '';
		$showrelated = '';
		$showdate = '';
		$showsec = '';
		$showcat = '';
		$showtag ='';
		$showhit ='';
		$showuser = '';
		$showsocial ='';
		$key = '';
		$view = '';
		if($this->id!=''){
			$info = $this->GetCatalogueInfo($this->id);
			$namevi = $this->TranslateByLang($info['name'], 'vi');
			$nameen = $this->TranslateByLang($info['name'], 'en');
			$keyword = $info['keyword'];
			$descript = $info['description'];
			$introvi = $this->TranslateByLang($info['intro'], 'vi');
			$introen = $this->TranslateByLang($info['intro'], 'en');
			$section = $info['section'];
			$showrelated = $info['showrelated'];
			$showdate = $info['showdate'];
			$showsec = $info['showsec'];
			$showcat = $info['showcat'];
			$showtag =$info['showtag'];
			$showhit =$info['showhit'];
			$showuser = $info['showuser'];
			$showsocial =$info['showsocial'];
			$key = $info['key'];
			$view = $info['view'];
		}
		echo '<div class="first">';
			echo '<div class="element">';
				echo '<div class="eleft">Tên danh mục : </div>';
				echo '<div class="eright"><input type="text" name="namevi" value="'.$namevi.'"></div>';
			echo '</div>';
			if($siteinfo['status']==1){
				echo '<div class="element">';
				echo '<div class="eleft">Catalogue name : </div>';
				echo '<div class="eright"><input type="text" name="nameen" value="'.$nameen.'"></div>';
				echo '</div>';
			}
			echo '<div class="element">';
				echo '<div class="eleft">Keywords : </div>';
				echo '<div class="eright"><input type="text" name="keyword" value="'.$keyword.'"></div>';
			echo '</div>';
		echo '</div>';
		echo '<div class="second">';
			echo '<div class="element">';
				echo '<div class="eleft">Chọn thể loại : </div>';
				echo '<div class="eright">';
					echo '<select id="section" name="section" >';
					foreach ($this->GetAllSection() as $value) {
						$selected = '';if($section == $value['id'])$selected = ' selected="selected"'; 
						$title = $this->TranslateByLang($value['name'], 'vi');
						if($siteinfo['status']==1)$title = $this->TranslateByLang($value['name'], 'vi').' - '.$this->TranslateByLang($value['name'], 'en');
						echo '<option'.$selected.' value="'.$value['id'].'">'.$title.'</option>';
					}
					echo '</select>';
				echo '</div>';
			echo '</div>';
			if($this->id!=''){
				echo '<div class="element">';
					echo '<div class="eleft">Hình ảnh : </div>';
					echo '<div class="eright"><img class="formimg" src="'.$this->ImageUrl('news', $info['image']).'"></div>';
				echo '</div>';
			}
			
			echo '<div class="element">';
				echo '<div class="eleft">Chọn Hình ảnh : </div>';
				echo '<div class="eright"><input type="file" id="image" name="image" ></div>';
			echo '</div>';
		echo '</div>';
		echo '<div class="clear"></div>';
		echo '<div class="last">';
			echo '<div class="element">';
				echo '<div class="eleft">Giới thiệu ngắn : </div>';
				echo '<div class="eright"><textarea name="introvi">'.$introvi.'</textarea></div>';
			echo '</div>';
			if($siteinfo['status']==1){
				echo '<div class="element">';
					echo '<div class="eleft">Short introdution : </div>';
					echo '<div class="eright"><textarea name="introen">'.$introen.'</textarea></div>';
				echo '</div>';
			}
			echo '<div class="element">';
				echo '<div class="eleft">Description : </div>';
				echo '<div class="eright"><textarea name="description">'.$descript.'</textarea></div>';
			echo '</div>';
			echo '<div class="element">';
				echo '<div class="eleft">Chọn kiểu hiển thị : </div>';
				echo '<div class="eright"><select name="view">';
				$comp = new Administrator_Model_Component();
				foreach ($comp->GetAllViewByAddon('2') as $value) {
					$selected = '';if($view == $value['id']) $selected = 'selected = "selected"';
					echo '<option '.$selected.' value="'.$value['id'].'">'.$value['display'].'</option>';
				}
				echo '</select></div>';
			echo '</div>';
			echo '<div class="element">';
				$checked = ' checked="checked"';if($showrelated==1)$checked = '';
				echo '<label class="checkbox" for="showrelated"><input'.$checked.' id="showrelated" type="checkbox" name="showrelated">Bài viết liên quan</label>';
				$checked = ' checked="checked"';if($showdate==1)$checked = '';
				echo '<label class="checkbox" for="showdate"><input'.$checked.' id="showdate" type="checkbox" name="showdate">Ngày đăng</label>';
				$checked = ' checked="checked"';if($showcat==1)$checked = '';
				echo '<label class="checkbox" for="showcat"><input'.$checked.' id="showcat" type="checkbox" name="showcat">Danh mục</label>';
				$checked = ' checked="checked"';if($showsec==1)$checked = '';
				echo '<label class="checkbox" for="showsec"><input'.$checked.' id="showsec" type="checkbox" name="showsec">Thể loại</label>';
				
				$checked = ' checked="checked"';if($showtag==1)$checked = '';
				echo '<label class="checkbox" for="showtag"><input'.$checked.' id="showtag" type="checkbox" name="showtag">Hiển thị tag</label>';			
				$checked = ' checked="checked"';if($showhit==1)$checked = '';
				echo '<label class="checkbox" for="showhit"><input'.$checked.' id="showhit" type="checkbox" name="showhit">Lượt xem</label>';
				
				$checked = ' checked="checked"';if($showuser==1)$checked = '';
				echo '<label class="checkbox" for="showuser"><input'.$checked.' id="showuser" type="checkbox" name="showuser">Người đăng</label>';
				$checked = ' checked="checked"';if($showsocial==1)$checked = '';
				echo '<label class="checkbox" for="showsocial"><input'.$checked.' id="showsocial" type="checkbox" name="showsocial">Social Icon</label>';
				$checked = ' checked="checked"';if($key==1)$checked = '';
				echo '<label class="checkbox" for="key"><input'.$checked.' id="key" type="checkbox" name="key">Key</label>';									
			echo '</div>';
		echo '</div>';
	}
}